package com.shd.edanpei.customer.adapter;

import android.content.Context;
import android.view.View;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shd.edanpei.R;
import com.shd.edanpei.base.BaseQuickImageAdapter;
import com.shd.edanpei.bean.OrderListModel;
import com.shd.edanpei.enums.OrderTypeEnum;
import com.shd.edanpei.enums.StatusEnum;

/**
 * Created by mc on 2018/9/18.
 * yang-wen-wen
 */

public class COrderAdapter extends BaseQuickImageAdapter<OrderListModel> {

    public COrderAdapter(Context context) {
        super(context, R.layout.item_corder);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderListModel item) {

        helper.setText(R.id.tv_orderNo, "订单编号：" + item.getOrderNo())
                .setText(R.id.tv_status, StatusEnum.getCDes(item.getUserStatus()))
                .setText(R.id.tv_name, item.getCustomerName())
                .setText(R.id.tv_time, item.getCreateTime())
                .setText(R.id.tv_info, item.getInfo())
                .setText(R.id.tv_amount, item.getApplyAmount())
                .setText(R.id.tv_type, OrderTypeEnum.getValue(item.getOrderType()))
                .setText(R.id.tv_pay_type, item.getPayType())
                //.setText(R.id.tv_pay_hint, item.getPayHint())
                .addOnClickListener(R.id.tv_pay)
                .addOnClickListener(R.id.tv_payService)
                .addOnClickListener(R.id.tv_sure);

        helper.getView(R.id.tv_pay).setVisibility(View.GONE);
        helper.getView(R.id.tv_payService).setVisibility(View.GONE);
        helper.getView(R.id.tv_unsure).setVisibility(View.GONE);
        helper.getView(R.id.tv_sure).setVisibility(View.GONE);

        if (item.getUserStatus() == StatusEnum.unpaid.getStatus()) {
            helper.getView(R.id.tv_pay).setVisibility(View.VISIBLE);
            helper.getView(R.id.tv_pay_type).setVisibility(View.VISIBLE);
            helper.getView(R.id.tv_pay_hint).setVisibility(View.VISIBLE);
        } else if (item.getUserStatus() == StatusEnum.waitService.getStatus()) {
            helper.getView(R.id.tv_payService).setVisibility(View.VISIBLE);
            helper.getView(R.id.tv_pay_type).setVisibility(View.VISIBLE);
            helper.getView(R.id.tv_pay_hint).setVisibility(View.VISIBLE);
        } else if (item.getUserStatus() == StatusEnum.waitLoan.getStatus()) {
            helper.getView(R.id.tv_unsure).setVisibility(View.VISIBLE);
        } else if (item.getUserStatus() == StatusEnum.waitfirm.getStatus()) {
            helper.getView(R.id.tv_sure).setVisibility(View.VISIBLE);
            helper.getView(R.id.tv_pay_type).setVisibility(View.GONE);
            helper.getView(R.id.tv_pay_hint).setVisibility(View.GONE);
        } else {
            helper.getView(R.id.tv_pay).setVisibility(View.GONE);
            helper.getView(R.id.tv_pay_type).setVisibility(View.GONE);
            helper.getView(R.id.tv_pay_hint).setVisibility(View.GONE);
        }

    }

}
